package 第k个数;

import java.util.Scanner;

public class Main {
    static int N = 100010, n;
    static int[] a = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        int k = in.nextInt();
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        System.out.println(qSort(0, n - 1, k));
    }

    private static int qSort(int l, int r, int k) {
        if (l >= r) {
            return a[l];
        }
        int i = l - 1, j = r + 1, x = a[l + r >> 1];
        while (i < j) {
            do {
                i++;
            } while (a[i] < x);
            do {
                j--;
            } while (a[j] > x);
            if (i < j) {
                swap(i, j);
            }
        }
        int sl = j - l + 1;
        if (sl >= k) {
            return qSort(l, j, k);
        }
        return qSort(j + 1, r, k - sl);
    }


    private static void swap(int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}
